var categoryUrl = ctx + "ajax/bcategory/getByParentId";
$(function () {
    $("#cOneId").change(function (o) {
        var cOneId = $("#cOneId").val();
        $.post(categoryUrl, {parentId: cOneId}, function (o) {
            var html = new Array();
            html.push("<select id=\"selTwoId\" name=\"selTwoId\"");
            html.push("<option value=''>全部</option>");
            var len = o.data == undefined ? 0 : o.data.length;
            for (var i = 0; i < len; i++) {
                var obj = o.data[i];
                var id=obj.id;
                var name=obj.categoryName;
                // if (i==0)
                html.push("<option value=\"" + id + "\">" + name + "</option>");
            }
            html.push("</select>");
            $("#span_c_two_id").html(html.join(''));
        });

    });

    $("#selcOneId").change(function () {
        var cOneId = $("#selcOneId").val();
        $.post(categoryUrl, {parentId: cOneId}, function (o) {
            var html = new Array();
            html.push("<select id=\"selcTwoId\" name=\"selcTwoId\" class=\"form-control\" onchange=\"changeTwoCategory(this)\" >");
            html.push("<option value=''>全部</option>");
            var len = o.data == undefined ? 0 : o.data.length;
            for (var i = 0; i < len; i++) {
                var obj = o.data[i];
                html.push("<option value=\"" + obj.id + "\">" + obj.categoryName + "</option>");
            }
            html.push("</select>");
            $("#span_c_two_id").html(html.join(''));
        });
    });
});
